/**
 * 
 */
package com.uobgroup.ews.uam.web;

import java.util.HashMap;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.uobgroup.ews.uam.core.model.ReferenceResultList;
import com.uobgroup.ews.uam.core.model.ReferenceResultParamsName;
import com.uobgroup.ews.uam.core.model.ReferenceTypeResultList;
import com.uobgroup.ews.uam.core.service.PickListsService;

/**
 * @author phuongtran
 * 
 */

@RequestMapping("/PickLists")
@Controller
public class PickListsController {

   @Autowired
   PickListsService pickListsService;

   @RequestMapping(method = RequestMethod.GET, value = "/getAllReferenceType", headers = "Accept=application/xml")
   public @ResponseBody
   ReferenceTypeResultList getReferenceTypeResultList() {
      return pickListsService.getReferenceTypeResultList();
   }

   @RequestMapping(method = RequestMethod.GET, value = "/getReference", headers = "Accept=application/xml")
   public @ResponseBody
   ReferenceResultList getReferenceResultList(
         @RequestParam(value = "referenceType", required = true) String referenceTypeId,
         @RequestParam(value = "doctype", required = false) String doctype,
         @RequestParam(value = "country", required = false) String country,
         @RequestParam(value = "processingcenter", required = false) String processingcenter,
         @RequestParam(value = "transactiontype", required = false) String transactiontype,
         @RequestParam(value = "producttype", required = false) String producttype,
         @RequestParam(value = "userlocation", required = false) String userlocation) {

      HashMap<String, String> params = new HashMap<String, String>();
      params.put(ReferenceResultParamsName.REFERENCE_TYPE_ID, referenceTypeId);

      return pickListsService.getReferenceResultList(params);
   }

}
